<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: 白菜你个cabbage
  Date: 2019/11/7
  Time: 11:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>IT图书</title>
</head>
<body>
<div align="center">
    <h2 align="center">欢迎来到21世纪书店</h2>
    图书分类>>>
    <a href="historyBook.jsp">历史类图书</a>
    <a href="IT.jsp">计算机类图书</a><br>
    <p>***书籍列表***</p>
    <form action="" method="post">
        <input type="text" name="book" value="《Java Web程序设计》郭克华 39.5元" size="40" maxlength="200" readonly>
        <input type="submit" name="add" value="加入购物车" height="2">
    </form>
    <form action="" method="post">
        <input type="text" name="book" value="《Android Studio实战》【美】 47.2元" size="40" maxlength="200" readonly>
        <input type="submit" name="add" value="加入购物车" height="2">
    </form>
    <%
        request.setCharacterEncoding("utf-8");
        String book = request.getParameter("book");
        ArrayList books = (ArrayList) session.getAttribute("books");
        if (books == null) {
            books = new ArrayList();
            session.setAttribute("books", books);
        }
        if (book != null) {
            books.add(book);
            out.println("<script type='text/javascript'>alert('加入购物车成功');</script>");
        }
    %>
    <br>
    <input type="button" value="查看我的购物车 " onClick="location.href='CarT.jsp'"><br>
</div>
</body>
</html>
